package com.ruoyi.chiwen.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.chiwen.domain.TbAlsomoney;
import com.ruoyi.chiwen.service.ITbAlsomoneyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 还款记录Controller
 * 
 * @author chiwen
 * @date 2021-06-14
 */
@RestController
@RequestMapping("/chiwen/alsomoney")
public class TbAlsomoneyController extends BaseController
{
    @Autowired
    private ITbAlsomoneyService tbAlsomoneyService;

    /**
     * 查询还款记录列表
     */
    @PreAuthorize("@ss.hasPermi('chiwen:alsomoney:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbAlsomoney tbAlsomoney)
    {
        startPage();
        List<TbAlsomoney> list = tbAlsomoneyService.selectTbAlsomoneyList(tbAlsomoney);
        return getDataTable(list);
    }

    /**
     * 导出还款记录列表
     */
    @PreAuthorize("@ss.hasPermi('chiwen:alsomoney:export')")
    @Log(title = "还款记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbAlsomoney tbAlsomoney)
    {
        List<TbAlsomoney> list = tbAlsomoneyService.selectTbAlsomoneyList(tbAlsomoney);
        ExcelUtil<TbAlsomoney> util = new ExcelUtil<TbAlsomoney>(TbAlsomoney.class);
        return util.exportExcel(list, "还款记录数据");
    }

    /**
     * 获取还款记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('chiwen:alsomoney:query')")
    @GetMapping(value = "/{sId}")
    public AjaxResult getInfo(@PathVariable("sId") Long sId)
    {
        return AjaxResult.success(tbAlsomoneyService.selectTbAlsomoneyById(sId));
    }

    /**
     * 新增还款记录
     */
    @PreAuthorize("@ss.hasPermi('chiwen:alsomoney:add')")
    @Log(title = "还款记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbAlsomoney tbAlsomoney)
    {
        return toAjax(tbAlsomoneyService.insertTbAlsomoney(tbAlsomoney));
    }

    /**
     * 修改还款记录
     */
    @PreAuthorize("@ss.hasPermi('chiwen:alsomoney:edit')")
    @Log(title = "还款记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbAlsomoney tbAlsomoney)
    {
        return toAjax(tbAlsomoneyService.updateTbAlsomoney(tbAlsomoney));
    }

    /**
     * 删除还款记录
     */
    @PreAuthorize("@ss.hasPermi('chiwen:alsomoney:remove')")
    @Log(title = "还款记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sIds}")
    public AjaxResult remove(@PathVariable Long[] sIds)
    {
        return toAjax(tbAlsomoneyService.deleteTbAlsomoneyByIds(sIds));
    }
}
